package main

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	filepath2 "path/filepath"
)



//更新json
type Version struct {
	Version string
	Url string
}

func main()  {
	filePath,_:=filepath2.Abs("./data/version.json")
	goPath,_:=filepath2.Abs("./data/version.go")
	b,err:=ioutil.ReadFile(filePath)
	if err!=nil{
		panic(err)
	}
	ver:=new(Version)
	err=json.Unmarshal(b,ver)
	if err!=nil{
		panic(err)
	}
	str:= fmt.Sprintf(`
package data

var Version = "%s"

//更新json
type VersionInfo struct {
	Version string
	Url string
}
`,ver.Version)
err=ioutil.WriteFile(goPath,[]byte(str),0644)
	if err != nil {
	    panic(err)
	}
}
